using System;
using System.Collections.Generic;
using System.Text;
using CodeStory.Core.ObjectEntity;
using CodeStory.Core.Providers;
using System.Web;

namespace CodeStory.Core.ObjectBusiness
{
	public class SiteMapBusiness
	{
		private SiteMapBusiness() {

		}

		public void InsertSiteMap(string nodeKey, string parentNodeKey, string title, string description, string url) {
			//string url = "~/default.aspx?pageid=" + page.PageID.ToString();
			SiteMapObject obj = SiteMapObject.ReadFirst("Url=@Url", "@Url", url);
			if (obj != null) {
				return;
			}

			SiteMapObject si = SiteMapObject.New();
			si.Description = description;
			si.NodeKey = nodeKey;
			si.ParentNodeKey = parentNodeKey;
			si.Title = title;
			si.Url = url;
			si.Save();
			IRefreshable refresh = SiteMap.Provider as IRefreshable;
			if (refresh != null) {
				refresh.Refresh();
			}
		}
	}
}
